package lesson06;

public class Cas {
    enum ReadyToRun{T1,T2};
    volatile static ReadyToRun r = ReadyToRun.T1;

    public static void main(String[] args) {

        char[] cI = "1234567".toCharArray();
        char[] cA = "ABCDEFG".toCharArray();

        new Thread(()->{
            for (char c : cI) {
                while ( r != ReadyToRun.T1){}
                    System.out.print(c);
                    r = ReadyToRun.T2;

            }
        },"t1").start();
        new Thread(()->{
            for (char c : cA) {
                while (r != ReadyToRun.T2){}
                    System.out.print(c);
                    r = ReadyToRun.T1;

            }
        },"t2").start();
    }
}
